import request from './request';

// 错题模块API
export function getWrongQuestions(params: any) {
  return request({
    url: '/api/wrong-question/questions',
    method: 'get',
    params,
  });
}
// export function getWrongQuestions(params: {
//   pageNum?: number;
//   pageSize?: number;
//   questionType?: string;
//   difficulty?: string;
//   category?: string;
//   keyword?: string;
// }) {
//   return request({
//     url: '/api/wrong-question/questions',
//     method: 'get',
//     params,
//   });
// }

// 获取练习题目
export function getPracticeQuestions(params: any) {
  return request({
    url: '/api/wrong-question/practice',
    method: 'get',
    params,
  });
}

// 通用接口名称
export function getQuestions(params: any) {
  return getWrongQuestions(params);
}

export function addWrongQuestion(data: any) {
  return request({
    url: '/api/wrong-question/questions',
    method: 'post',
    data,
  });
}

// 通用接口名称
export function addQuestion(data: any) {
  return addWrongQuestion(data);
}

export function updateWrongQuestion(id: string, data: any) {
  return request({
    url: `/api/wrong-question/questions/${id}`,
    method: 'put',
    data,
  });
}

// 通用接口名称
export function updateQuestion(id: string, data: any) {
  return updateWrongQuestion(id, data);
}

export function deleteWrongQuestion(id: string) {
  return request({
    url: `/api/wrong-question/questions/${id}`,
    method: 'delete',
  });
}

// 批量删除错题
export function batchDeleteWrongQuestions(ids: string[]) {
  return request({
    url: '/api/wrong-question/questions/batch',
    method: 'delete',
    data: ids
  });
}

// 通用接口名称
export function deleteQuestion(id: string) {
  return deleteWrongQuestion(id);
}

// 通用批量删除接口名称
export function batchDeleteQuestions(ids: string[]) {
  return batchDeleteWrongQuestions(ids);
}

// 提交答案
export function submitAnswer(data: any) {
  return request({
    url: '/api/wrong-question/submit',
    method: 'post',
    data,
  });
}

export function getWrongQuestion(id: number | string) {
  return request({
    url: `/api/wrong-question/questions/${id}`,
    method: 'get',
  });
}

// 通用接口名称
export function getQuestion(id: number | string) {
  return getWrongQuestion(id);
}